const timeFormat = (time, simple = 0) => {
  const date = new Date(time)
  const year = date.getFullYear()
  const month = padZero(date.getMonth() + 1)
  const day = padZero(date.getDate())
  const hour = padZero(date.getHours())
  const minute = padZero(date.getMinutes())
  // simple为0返回年月日，为1返回年月日加时分
  return `${year}-${month}-${day}${simple === 1 ? ` ${hour}:${minute}` : ''}`
}

const padZero = (n) => (n < 10 ? '0' + n : n)

export default timeFormat
